using namespace std;
#include <vector>
#include <queue>

class Node
{
public:
    int val{};
    vector<Node*> children;
    Node() = default;
    explicit Node(int _val)
    {
        val = _val;
    }
    Node(int _val, vector<Node*> _children)
    {
        val = _val;
        children = _children;
    }
};


class Solution 
{
public:
    static vector<vector<int>> levelOrder(Node* root)
    {
        vector<vector<int>> vv;
        if(root == nullptr)
            return vv;
        queue<Node*> q;
        q.push(root);
        while(!q.empty())
        {
            int num = q.size();
            vector<int> tmp;
            for(int i=0; i<num; i++)
            {
                Node* t = q.front();
                q.pop();
                tmp.push_back(t->val);
                for(auto child : t->children)
                {
                    if(child != nullptr)
                        q.push(child);
                }
            }
            vv.push_back(tmp);
        }
        return vv;
    }
};